package com.woniuxy.yoga.controller;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradePagePayRequest;
import com.woniuxy.yoga.config.AlipayConfig;
import com.woniuxy.yoga.service.AlipayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

/**
 * Created by  on 2019-9-09.
 */
@RestController
@RequestMapping("/pay")
public class AlipayController {

    @Autowired
    AlipayService alipayService;


    @RequestMapping("/payer/{money}")
    @CrossOrigin
    public void payMent(HttpServletResponse response, HttpServletRequest request,@PathVariable("money") String money) {
        try {
            alipayService.aliPay(response,request,money);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}